<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件化的基本使用</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <!-- 俩个都是局部组件 -->
        <!-- 组件组 -->
      <cpn1></cpn1> 
      <!-- 父组件 -->
      <cpn2></cpn2>
    </div>
    <script>
        //1. 创建组件构造器对象 (子组件)
        const cpnC1 = Vue.extend({
            template:`
                <div>
                    <h2>我是标题1</h2>
                    <p>我是内容1</p>
                    <p>我也是内容1</p>
                    
                </div>
                `
        })
        //父组件
        const cpnC2 = Vue.extend({
            template:`
                <div>
                    <h2>我是标题2</h2>
                    <p>我是内容2</p>
                    <p>我也是内容2</p>
                    <cpn1></cpn1>
                </div>
                `,
                components: {//注册组件1
                    cpn1: cpnC1
                }
        })

        //2. 注册组件
        const app = new Vue({
            el: "#app",
            data: {
                
            },
            components: {
                cpn2: cpnC2,
                cpn1: cpnC1
            }
        })
    </script>
</body>
</html>